<template>
  <div>
    <FormPanel ref="from" :list="formList" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />

    <div style="height: 47px"></div>
    <BreakSpace label="价格折扣信息" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable ref="table" :columns="columns" :dataSource="list" :onColumnsChange="columns => (this.columns = columns)" :isSelectColumn="false"></FilterTable>
    <div style="height: 47px"></div>
    <BreakSpace label="操作记录" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable ref="tableLog" :columns="columnsLog" :dataSource="list" :onColumnsChange="columns => (this.columnsLog = columns)" :isSelectColumn="false"></FilterTable>
    <div style="height: 47px"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">返回</el-button>
    </div>
  </div>
</template>
<script>
import moment from 'moment';
import { getList, postSave, getWarehouseList } from '@/api/dealerSale/InventoryManagement/MoveStorehouse';
import { dictionary } from '@/utils/dictMixin';
import { copyUpdateData } from '@/utils/index';

export default {
  name: 'addModel',
  props: ['rowData'], // 上个页面带入的值
  data() {
    this.saveData = null;
    this.BaseTable = null;
    return {
      formList: this.createdFrom(),
      columns: this.createdTable(),
      columnsLog: this.createdLogTable(),
      list: [],
      fromData: {}
    };
  },
  created() {
    this.getList();
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  mixins: [dictionary],
  methods: {
    async getList() {
      // let res = await getList(); 发送请求
      // this.list = res.data; 赋值参数
      // this.fromData = res.data;
      this.list = [
        {
          vehicleStatus: 'EU5',
          vin: '123'
        }
      ];
    },
    submitFn() {
      let table = this.BaseTable.GET_REQUIRED_ERROR();
      this.$refs.from.SUBMIT_FORM();
      if (!table && this.saveData) {
        this.$emit('save');
      }
    },
    saveFn() {
      this.fromData = copyUpdateData(this.fromData, this.saveData);
      this.$emit('save');
    },
    closeDrawer() {
      this.$emit('close');
    },
    changeHandle(val) {
      this.saveData = val;
    },
    createdFrom() {
      return [
        {
          type: 'INPUT',
          label: '订货单编号',
          fieldName: 'orderNo',
          placeholder: '请输入',
          disabled: true
        },
        {
          type: 'DATE',
          label: '当前年月',
          fieldName: 'YearMonth',
          placeholder: '请输入',
          disabled: true,
          dateType: 'month',
          initialValue: moment().format('YYYY-MM')
        },
        {
          type: 'SELECT',
          label: '订单状态',
          fieldName: 'orderStatus',
          placeholder: '请选择',
          disabled: true,
          itemList: this.createDictList('6002')
        },
        {
          type: 'SELECT',
          label: '订单类型',
          fieldName: 'orderType',
          placeholder: '请选择',
          disabled: true,
          itemList: this.createDictList('6006')
        },
        {
          type: 'SELECT',
          label: '订单细分类型',
          fieldName: 'orderDetailType',
          placeholder: '请选择',
          disabled: true,
          itemList: []
        },
        {
          type: 'INPUT',
          label: '订单经销商',
          fieldName: 'dealerName',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '整车编码',
          fieldName: 'productCode',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '整车编码描述',
          fieldName: 'productDesc',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '内饰',
          fieldName: 'trimName',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '销售订单号',
          fieldName: 'doNo',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'INPUT',
          label: 'VIN码',
          fieldName: 'vin',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '外饰',
          fieldName: 'colorName',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '收车地址',
          fieldName: 'address',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '资金类型',
          fieldName: 'accountTypeName',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '运输方式',
          fieldName: 'transportType',
          disabled: true,
          itemList: this.createDictList('6004')
        },
        {
          type: 'INPUT',
          label: '资金余额',
          fieldName: 'totalAmount',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '返利池余额',
          fieldName: 'singleRebateAmount',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '订单总金额',
          fieldName: 'buildRebateAmount',
          placeholder: '请选择',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '返利使用金额',
          fieldName: 'singleAmount',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '折扣总金额',
          fieldName: 'isRebate',
          disabled: true,
          itemList: this.createDictList('1004')
        },
        {
          type: 'INPUT',
          label: '折扣率',
          fieldName: 'rebateAmount',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '单车返利金额',
          fieldName: 'singleRebateAmount',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '建店返利金额',
          fieldName: 'buildRebateAmount',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '实付总金额',
          fieldName: 'discount',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '市场指导价',
          fieldName: 'singleAmount',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '折后单价',
          fieldName: 'afterDiscountAmount',
          disabled: true
        },
        {
          type: 'TEXT_AREA',
          label: '备注',
          fieldName: 'remark',
          disabled: true,
          selfCols: 3,
          rows: 2
        }
      ];
    },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '折扣规则名称',
          dataIndex: 'vehicleStatus'
        },
        {
          title: '动力形式',
          dataIndex: 'vin'
        },
        {
          title: '返利用途',
          dataIndex: 'distributionStatus'
        },
        {
          title: '折扣计算方式',
          dataIndex: 'isLock'
        },
        {
          title: '折扣值',
          dataIndex: 'lockRemark'
        },
        {
          title: '单车折扣金额',
          dataIndex: 'isFreeze'
        },
        {
          title: '折扣前单价',
          dataIndex: 'freezeReason'
        },
        {
          title: '折扣后单价',
          dataIndex: 'freezeDate'
        }
      ];
    },
    createdLogTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '单据执行前状态',
          dataIndex: 'frontStatus',
          filterType: 'checkbox',
          filterItems: this.createDictList('6076'),
          render: props => {
            return <span>{this.createDictText(props.row.frontStatus, '6076')}</span>;
          }
        },
        {
          title: '单独执行后状态',
          dataIndex: 'returnStatus',
          filterType: 'checkbox',
          filterItems: this.createDictList('6076'),
          render: props => {
            return <span>{this.createDictText(props.row.returnStatus, '6076')}</span>;
          }
        },
        {
          title: '操作人员',
          dataIndex: 'createdByName'
        },
        {
          title: '操作时间',
          dataIndex: 'createdAt'
        },
        {
          title: '操作类型',
          dataIndex: 'operation'
        },
        {
          title: '审批意见',
          dataIndex: 'remark'
        }
      ];
    }
  }
};
</script>
